<%@page import="com.jewaton.auth.commons.util.Constants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/commons/script.jsp" %>
    <title>安全系统—角色列表</title>
<body>
  <div class="m_right">

    <div class="m_r_tips">
        <div class="m_r_lefttips">您现在的位置：<a href="${ctx}/admin/home.jsp">首页</a>&gt;系统管理&gt;角色管理</div>
        <jsp:include page="/commons/admin/admin_login_remind.jsp"/>
    </div>

	<s:form id="list_form" method="post" action="findAllPcRole" namespace="/admin/role">
    <div class="m_r_list">
       <div class="m_r_list_pic"></div>
       <div class="m_l_list_search">关键词：
             <span class="borderHover"><input name="keywork1" id="keywork1" value="${keywork1}" placeholder="角色名称" class="text_input_1"/>
            	 所属机构：<select class="textInput2" name="orgId" id="orgId">
              	      	<s:iterator var="n" value="#request.orgSelectBox">
             				 <option value="${n.oid}">${ n.name}</option>
             			</s:iterator>
              	 </select>
           	</span>
               <a href="#" class="m_r_bnt1"><input type="submit" name="Submit" value="查询"/></a>
       </div>
    </div>
    </s:form>
    
    <s:if test="#session.DO_FEEDBACK != null" >
           <div class="m_r_tips">
               <div class="m_r_lefttips"><span style="color:red">
                  ${DO_FEEDBACK}
                  <% session.removeAttribute("DO_FEEDBACK"); %>
               </span></div>
          </div>
    </s:if>


    <div class="m_r_table">
       <table width="100%" border="0" cellspacing="1" cellpadding="0">
         <thead>
          <tr>
            <td class="m_r_table_td" colspan="10" >
            <a href="${ctx}/admin/role/addPcRole.do"><img src="${ctx}/images/list1.gif">新增</a>&nbsp;&nbsp;|&nbsp;&nbsp;
            <a href="#" id="go_del"><img src="${ctx}/images/list6.gif"/>删除</a></td>
            </tr>
          <tr>
            <td class="m_r_table_tr bold"><input type="checkbox" value="" id = "p_box"/></td>
            <td class="m_r_table_tr bold">角色名称</td>
            <td class="m_r_table_tr bold">角色描述</td>
            <td class="m_r_table_tr bold">组织</td>
            <td class="m_r_table_tr bold">创建人</td>
            <td class="m_r_table_tr bold">创建日期</td>
            <td class="m_r_table_tr bold">修改人</td>
            <td class="m_r_table_tr bold">修改日期</td>
            <td class="m_r_table_tr bold">操作</td>
          </tr>
          </thead>
          <tbody>
          
              <s:if test="session.account">
              
              </s:if>
         <s:iterator value="pager.list" status="rowstatus" var="role">
               <tr>
                    <td><input type="checkbox" value="${role.rid }" name = "s_box" ${role.isSystem == "true" ? "disabled = 'disabled'" : "" }/></td>
                    <td>${role.roleName}</td>
                    <td>${role.description}</td>
                    <td>${role.organization.name}</td>
                    <td>
                        ${empty role.createUser && role.isSystem ? "系统内置" : role.createUser.username}
                    </td>
                    <td><s:date name="#role.createTime" format="yyyy-MM-dd HH:mm:ss"/></td>
                    <td>${role.modifyUser.username}</td>
                    <td><s:date name="#role.modifyTime" format="yyyy-MM-dd HH:mm:ss"/></td>   
                    <td>
                      <s:if test="#role.isSystem">
                                                                                    系统内置 |
                      </s:if>  
                      <s:else>
                        <a href="${ctx}/admin/role/goToPermRole.do?rid=${role.rid}">分配权限</a> |
                       </s:else>
<%--                         <a href="${ctx}/admin/role/goToPermRole.do?rid=${role.rid}">分配权限</a> | --%>
                        <a href="${ctx}/admin/role/viewRolePerm.do?rid=${role.rid}">查看权限</a>
                    </td>
              </tr>
             </s:iterator>
           
           
          </tbody>
        </table>
    </div>
    
    <div class="pageDiv">
       <span class="pageL">共有<font color="#0e83af">${pager.totalRecord}</font>条数据</span>
       <div id="pager"></div>
   </div>    
</div>
</body>
<script src="${ctx}/js/checkbox-table.js" type="text/javascript"></script>
<script type="text/javascript">

     
if ('${PC_ACCOUNT.organization.oid}' == '<%=Constants.CITY_ORG_CODE%>') {
	$("#orgId").prepend("<option value=''>全部</option>");
}

$(document).ready(function(){
		$("#orgId").val('${orgId}');
});

$("#go_del").click(function(){
    var c = getCheckCountByName('s_box');
    if (c == 0){
      alert("请选择要删除的角色");
      return;
    }
    var ids = escape(getCheckValues());
    if (window.confirm('确定删除吗')) {
        window.location.href = "${ctx}/admin/role/delRoles.do?ids=" + ids;
    }
});


$("#go_auth").click(function(){
    var c = getCheckCount();
    if (c > 1) {
      alert("只能选择一个角色");
      return;
    } else if (c == 0){
      alert("请选择要分配的角色");
      return;
    }
    var single_box_value = getCheckValues();
    single_box_value = single_box_value.replace(/#/,"");
    window.location.href = "${ctx}/admin/role/goToPermRole.do?rid=" + single_box_value;
});

$("#go_view").click(function(){
    var c = getCheckCount();
    if (c > 1) {
      alert("只能选择一个角色");
      return;
    } else if (c == 0){
      alert("请选择要分配的角色");
      return;
    }
    var single_box_value = getCheckValues();
    single_box_value = single_box_value.replace(/#/,"");
    window.location.href = "${ctx}/admin/role/viewRolePerm.do?rid=" + single_box_value;
});

$("#pager").pager({ pagenumber: '${pager.pageNo}', pagecount: '${pager.totalPage}', 
	pagesize:'${pager.pageSize}', submitType:'form', formId:'list_form'});

</script>
</html>
